﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Baza.EF.DAL;
namespace Baza.EF.BLL

{
    public class DAAdmin
    {


        public static int getTipusera(string email)
        {
            int temp = Convert.ToInt32(Connection.dm.ad_Login_By_Email(email).FirstOrDefault());

            return temp;           

        }

        public static ad_Login_Owner_By_Email_Result getOwnersByEmail(string email, string pass)
        {
            ad_Login_Owner_By_Email_Result o = Connection.dm.ad_Login_Owner_By_Email(email).FirstOrDefault();
            if (o != null)
            {

                if (UIHelper.GenerateHash(pass, o.PasswordSalt) == o.PasswordHash)
                {

                    return o;
                }
                else
                    return null;
            }
            else
                return null;

        }
        public static ad_Login_User_By_Email_Result getUsersByEmail(string email, string pass)
        {
            ad_Login_User_By_Email_Result o = Connection.dm.ad_Login_User_By_Email(email).FirstOrDefault();
            if (o != null)
            {

                if (UIHelper.GenerateHash(pass, o.PasswordSalt) == o.PasswordHash)
                {

                    return o;
                }
                else
                    return null;
            }
            else
                return null;
        }
        public static ad_Login_Customer_By_Email_Result getCustomersByEmail(string email, string pass)
        {
            ad_Login_Customer_By_Email_Result o = Connection.dm.ad_Login_Customer_By_Email(email).FirstOrDefault();
            if (o != null)
            {

                if (UIHelper.GenerateHash(pass, o.PasswordSalt) == o.PasswordHash)
                {

                    return o;
                }
                else
                    return null;
            }
            else
                return null;
        }


    }
}
